<template>
	<div id="subtmpl">
		<div class="inleft div" @click="substrict">-</div>
		<div class="incenter div" v-text="count"></div>
		<div class="inright div" @click="add">+</div>

	</div>
</template>
<script type="text/javascript">
	export default{
		props:['initCount','goodsId'],
		data(){
			return{
				count:1,
				resObj:{goodsId:0,type:'add'}
			}
		},
		created(){this.count=this.initCount},
		methods:{
			substrict(){
				this.count--;
				if (this.count<1) {
					this.count=1;
				}
				this.sendmessage('substrict');				
			},
			add(){
				this.count++;
				this.sendmessage('add');
			},
			sendmessage(type){
				this.resObj.type=type;
				this.resObj.goodsId=this.goodsId;
				this.$emit('carsend',this.resObj)
			}
		}
	}
</script>
<style type="text/css" scoped>
	#subtmpl {
		display: inline-block;
	}
	.div {
		width: 40px;
		height: 25px;
		border: 1px solid #000;
		display: inline-block;
		text-align: center;
	}
</style>
